[EWS] Creating recurring calendar event with breakouts

I am using EWS (direct XML, not the managed API) to create a recurring calendar event in Office 365. And at the same time, trying to enter in breakout events such as deleted or modified instances of the pattern. I've got the basic recurrence working but the breakouts don't seem to work. I am starting off just with deleted dates, for example:

<t:CalendarItem>
<t:Subject>Normal daily test</t:Subject>
<t:Importance>Low</t:Importance>
<t:ReminderMinutesBeforeStart>5</t:ReminderMinutesBeforeStart>
<t:ExtendedProperty>
<t:ExtendedFieldURI PropertyTag="0x3004" PropertyType="String"/>
<t:Value>via TM</t:Value>
</t:ExtendedProperty>
<t:Start>2015-06-22T22:30:00Z</t:Start>
<t:End>2015-06-22T23:30:00Z</t:End>
<t:LegacyFreeBusyStatus>Busy</t:LegacyFreeBusyStatus>
<t:Location></t:Location>
<t:Recurrence>
<t:DailyRecurrence>
<t:Interval>1</t:Interval>
</t:DailyRecurrence>
<t:NumberedRecurrence>
<t:StartDate>2015-06-22Z</t:StartDate>
<t:NumberOfOccurrences>7</t:NumberOfOccurrences>
</t:NumberedRecurrence>
</t:Recurrence>
<t:DeletedOccurrences>
<t:DeletedOccurrence>
<t:Start>2015-06-23T22:30:00Z</t:Start>
</t:DeletedOccurrence>
</t:DeletedOccurrences>
<t:StartTimeZone Id="Pacific Standard Time"></t:StartTimeZone>
</t:CalendarItem>
The result is the error "Set action is invalid for property".  It is definitely the <DeletedOccurrences> block causing the problem; if I take that out, it works fine.  Any ideas?

June 2nd, 2015 7:38pm

You can't create deleted occurrences when creating an appointment, you need to create the appointment first then use updateItem to create the Deleted occurrences. see https://msdn.microsoft.com/en-us/library/ee202882%28v=exchg.80%29.aspx "Specifies deleted occurrences of a recurring calendar item. This element is not valid if CalendarItemType is contained in a CreateItem request"

Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
June 3rd, 2015 12:09am

You can't create deleted occurrences when creating an appointment, you need to create the appointment first then use updateItem to create the Deleted occurrences. see https://msdn.microsoft.com/en-us/library/ee202882%28v=exchg.80%29.aspx "Specifies deleted occurrences of a recurring calendar item. This element is not valid if CalendarItemType is contained in a CreateItem request"

Cheers
Glen

June 3rd, 2015 4:07am

You can't create deleted occurrences when creating an appointment, you need to create the appointment first then use updateItem to create the Deleted occurrences. see https://msdn.microsoft.com/en-us/library/ee202882%28v=exchg.80%29.aspx "Specifies deleted occurrences of a recurring calendar item. This element is not valid if CalendarItemType is contained in a CreateItem request"

Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
June 3rd, 2015 4:07am

Thanks Glen.  I guess if Microsoft made EWS too easy, I would be out of a job...
June 3rd, 2015 12:19pm

I wonder if you can clarify a bit how you think I should do this - if I understand the idea, I would need the ItemId of the instance that I want to delete or change, right?  I saw an example of how I can get the item ids, using GetItem against the master recurrence, then requesting multiple OccurrenceItemId values, specifying an instance index.  Then I would compare the start date of each instance that I get to the one that I have to find the right Id.  The only problem with that plan, other than being grossly inefficient, is that what if the recurrence is infinite?  I guess I would just have to limit it at some point. 

Or am I misunderstanding something?  Were you suggesting that I call UpdateItem against the master recurrence, specifying somehow the deletes and mods that I want?  I would like to see an example of how that should be done.

Free Windows Admin Tool Kit Click here and download it now
June 3rd, 2015 7:59pm

>>  if I understand the idea, I would need the ItemId of the instance that I want to delete or change, right?

 You need the ItemId or you can use the OccurrenceItemId  https://msdn.microsoft.com/en-us/library/aa580744(v=exchg.150).aspx basically the MasterId and the Index value. There is explanation of the underlying storage item https://msdn.microsoft.com/en-us/library/cc500380.aspx

 You need to think of this in terms of what a client application can do as that's how most API are designed eg when a user use client X wether that be Outlook,OWA,Activesync use it this is going to be their behaviour. All the different methods and how to do it are listed in https://msdn.microsoft.com/en-us/library/office/dn727658%28v=exchg.150%29.aspx (Sorry UpdateItem was the wrong the op)

 >>The only problem with that plan, other than being grossly inefficient, is that what if the recurrence is infinite?

 (IMO)Not really if your creating a lot of deleted instances then you should rethink what your doing eg you probably using the wrong recurrence pattern or what you trying to achieve could be better archived through multiple appointments (In my experience infinite recurrences are bad practice and should be avoided they just create a mess that will need to be cleaned up in the future).

Cheers
Glen

June 4th, 2015 1:15am

>>  if I understand the idea, I would need the ItemId of the instance that I want to delete or change, right?

 You need the ItemId or you can use the OccurrenceItemId  https://msdn.microsoft.com/en-us/library/aa580744(v=exchg.150).aspx basically the MasterId and the Index value. There is explanation of the underlying storage item https://msdn.microsoft.com/en-us/library/cc500380.aspx

 You need to think of this in terms of what a client application can do as that's how most API are designed eg when a user use client X wether that be Outlook,OWA,Activesync use it this is going to be their behaviour. All the different methods and how to do it are listed in https://msdn.microsoft.com/en-us/library/office/dn727658%28v=exchg.150%29.aspx (Sorry UpdateItem was the wrong the op)

 >>The only problem with that plan, other than being grossly inefficient, is that what if the recurrence is infinite?

 (IMO)Not really if your creating a lot of deleted instances then you should rethink what your doing eg you probably using the wrong recurrence pattern or what you trying to achieve could be better archived through multiple appointments (In my experience infinite recurrences are bad practice and should be avoided they just create a mess that will need to be cleaned up in the future).

Cheers
Glen

  • Marked as answer by Jeff McKay 14 hours 9 minutes ago
Free Windows Admin Tool Kit Click here and download it now
June 4th, 2015 5:12am

Agreed about infinite recurrences, but this is a migration application, so I have to try and duplicate what the original calendar system was doing.
June 4th, 2015 1:23pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics